// /***/ "Xp4A":
/***/ const Xp4A = (function(module, __webpack_exports__, __webpack_require__) {

    "use strict";
    /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return decrypt; });
    /* unused harmony export decryptAdContent */
    /* unused harmony export decryptAdKey */
    /* unused harmony export aesGcmEncrypt */
    /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return aesGcmDecrypt; });
    /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return getThirdToken; });
    /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return createSign; });
    /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_md5__ = __webpack_require__("pMqz");
    /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_md5___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_md5__);
    __webpack_require__("+stQ").Crypto;
    var _crypto = __webpack_require__("Oygn");
    var Buffer = __webpack_require__("peL6").Buffer;
    
    
    var gcm = {
        b: '4e894B20a07c80331d1AC8A7e1b6c140',
        s: '34Ba50f5a51Be0192B4a6Dbb0AC51c30',
        as: '5fA05147846fb1528af053B770292C03'
    };
    
    var decrypt = function decrypt(ciphertext, key) {
        var mode = new Crypto.mode.CBC(Crypto.pad.pkcs7);
        var eb = Crypto.util.base64ToBytes(ciphertext);
        var kb = Crypto.util.base64ToBytes(key);
        var ub = Crypto.AES.decrypt(eb, kb, { asBytes: true, mode: mode });
        var content = Crypto.charenc.UTF8.bytesToString(ub).replace(/\s*\n*\s{2,}/g, '</p><p>');
        content = content.replace(/\n+/g, '</p><p>');
        content = '<p>' + content + '</p>';
        return content;
    };
    
    function inserAdBlock(content) {
        var contents = content.match(/<p>(.*?)<\/p>/g),
            contentsTemp = [],
            textIndex = 0,
            adIndex = 1;
        for (var i = 0; i < contents.length; i++) {
            textIndex += contents[i].match('<p.*?>(.*?)<\/p>')[1].length;
            if (textIndex >= 300 * adIndex) {
                contentsTemp.push(contents[i] + '<div class="chapter-ad-block" data-index=' + adIndex + ' data-ad-exposure="0" id="J_adBlock_' + adIndex + '"></div>');
                adIndex++;
            } else {
                contentsTemp.push(contents[i]);
            }
        }
        return contentsTemp.join('');
    }
    
    function obj2str(args) {
        var keys = Object.keys(args);
        keys = keys.sort(); //参数名ASCII码从小到大排序（字典序）；
        var newArgs = {};
        keys.forEach(function (key) {
            if (args[key] !== "" && args[key] !== 'undefined') {
                //如果参数的值为空不参与签名；
                newArgs[key] = args[key]; //参数名区分大小写；
            }
        });
        var string = '';
        for (var k in newArgs) {
            string += '&' + k + '=' + newArgs[k];
        }
        string = string.substr(1);
        return string;
    }
    var decryptAdContent = function decryptAdContent(ciphertext, key) {
        var mode = new Crypto.mode.CBC(Crypto.pad.pkcs7);
        var eb = Crypto.util.base64ToBytes(ciphertext);
        var kb = Crypto.util.base64ToBytes(key);
        var ub = Crypto.AES.decrypt(eb, kb, { asBytes: true, mode: mode });
        var content = Crypto.charenc.UTF8.bytesToString(ub).replace(/\s*\n*\s{2,}/g, '</p><p>');
        content = content.replace(/\n+/g, '</p><p>');
        content = '<p>' + content + '</p>';
        content = inserAdBlock(content);
        return content;
    };
    
    var decryptAdKey = function decryptAdKey(ciphertext, key) {
        var mode = new Crypto.mode.CBC(Crypto.pad.pkcs7);
        var eb = Crypto.util.base64ToBytes(ciphertext);
        var kb = Crypto.util.base64ToBytes(key);
        var ub = Crypto.AES.decrypt(eb, kb, { asBytes: true, mode: mode });
        return Crypto.charenc.UTF8.bytesToString(ub);
    };
    
    var aesGcmEncrypt = function aesGcmEncrypt(plaintext, Secret, Check) {
        var iv = _crypto.randomBytes(12);
        var cipher = _crypto.createCipheriv('aes-256-gcm', new Buffer(Secret, 'utf8'), iv);
        cipher.setAAD(new Buffer(Check));
    
        var enc = cipher.update(plaintext, 'utf8');
        cipher.final();
        return Buffer.concat([iv, enc, cipher.getAuthTag()]).toString('hex');
    };
    function getaesModes(){

    }

    // +KTb
    function createDecipheriv (suite, key, iv) {
        suite = suite.toLowerCase()
        if (aesModes[suite]) return aes.createDecipheriv(suite, key, iv)
        if (desModes[suite]) return new DES({ key: key, iv: iv, mode: suite, decrypt: true })
        throw new TypeError('invalid suite type')
      }
    var aesGcmDecrypt = function aesGcmDecrypt(plaintext) {
        var Secret = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '' + gcm.as;
        var Check = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '' + gcm.b;
    
    
        var text = Buffer.from(plaintext, 'base64');
        var iv = text.slice(0, 12);
        var tag = text.slice(text.length - 16, text.length);
    
        var key = new Buffer(Secret, 'utf8');
        var decipher = createDecipheriv('aes-256-gcm', key, iv);
        decipher.setAAD(new Buffer(Check));
        decipher.setAuthTag(tag);
    
        var enc = decipher.update(text.slice(12, text.length - 16));
        enc += decipher.final('utf8');
        return enc;
    };
    
    var getThirdToken = function getThirdToken() {
        return gcm.b + ':' + aesGcmEncrypt(JSON.stringify({ time: new Date().getTime() }), gcm.s, gcm.b);
    };
    
    var createSign = function createSign(data) {
        data = Object.assign({}, data, { key: 'bLilf61m' });
        var sign = __WEBPACK_IMPORTED_MODULE_0_md5___default()(obj2str(data));
        data.sign = sign;
        delete data.key;
        return data;
    };
    
    /***/ })

    export default Xp4A